package com.manor.paradise.adapter

import android.graphics.Color
import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.manor.paradise.R
import com.manor.paradise.activity.AddAddressActivity
import com.manor.paradise.bean.AddressBean

class AddressAdapter(layoutResId: Int, data: MutableList<AddressBean.RecordsBean>?) : BaseQuickAdapter<AddressBean.RecordsBean, BaseViewHolder>
(layoutResId, data) {

    override fun convert(baseViewHolder: BaseViewHolder, item: AddressBean.RecordsBean) {
        var tv_name = baseViewHolder.getView<TextView>(R.id.tv_name)
        tv_name.text = "姓名："+item.contacts
        var tv_tel = baseViewHolder.getView<TextView>(R.id.tv_tel)
        tv_tel.text = "联系电话"+item.mobile
        var tv_context = baseViewHolder.getView<TextView>(R.id.tv_context)
        tv_context.text = item.provinceName+item.cityName+item.areaName+item.address.toString()
        var im_mr = baseViewHolder.getView<ImageView>(R.id.im_mr)
        var tv_mr = baseViewHolder.getView<TextView>(R.id.tv_mr)

        if(item.isBdefault){
            im_mr.setImageResource(R.mipmap.pic_add_yx)
            tv_mr.setTextColor(Color.parseColor("#FF0FFCFF"))
            tv_mr.text = "已设为默认"
        }else{
            im_mr.setImageResource(R.mipmap.pic_add_wx)
            tv_mr.setTextColor(Color.parseColor("#ffffff"))
            tv_mr.text = "设为默认"
        }

        var tv_ed = baseViewHolder.getView<TextView>(R.id.tv_ed)
        tv_ed.setOnClickListener {
            AddAddressActivity.forward(context, item)
        }


    }

}
